import Vue from 'vue'
import App from './App.vue'
import router from './router'
// 导入页面滚动
import infiniteScroll from 'vue-infinite-scroll'
// 导入md编辑器插件
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
// 导入axios请求库
import axios from 'axios'
// 导入格式化时间模块
import dayjs from 'dayjs'
import {
    Button,
    Menu,
    MenuItem,
    Input,
    Tag,
    Loading,
    Dialog,
    Form,
    FormItem,
    Message,
    Container,
    Main,
    Aside,
    Table,
    TableColumn,
    Pagination,
    Drawer,
    Select,
    Option,
    Upload,
    MessageBox,
    Timeline,
    TimelineItem,
    Card
} from 'element-ui';
Vue.use(Timeline)
Vue.use(TimelineItem)
Vue.use(Card)
Vue.use(Upload)
Vue.use(Option)
Vue.use(Select)
Vue.use(Drawer)
Vue.use(Pagination)
Vue.use(Table)
Vue.use(TableColumn)
Vue.use(Container)
Vue.use(Aside)
Vue.use(Main)
Vue.use(Button)
Vue.use(Menu)
Vue.use(MenuItem)
Vue.use(Input)
Vue.use(Tag)
Vue.use(infiniteScroll)
Vue.use(Loading.directive)
Vue.use(Dialog)
    // 开启md编辑器
Vue.use(mavonEditor)
    // 取出本地token  存到Vue身上
Vue.prototype.token = localStorage.token ? localStorage.token : ''
Vue.prototype.userInfo = localStorage.userInfo && JSON.parse(localStorage.userInfo)
Vue.use(Form)
Vue.use(FormItem)
    // 挂载消息提示的方法
Vue.prototype.$message = Message
    // 挂载消息弹窗
Vue.prototype.$confirm = MessageBox.confirm
    // 去掉生产环境下的提示
Vue.config.productionTip = false
    // 配置axios的默认请求地址
axios.defaults.baseURL = 'http://localhost:8888'
    // 利用请求拦截器配置本地token
axios.interceptors.request.use(function(config) {
        if (localStorage.token) {
            config.headers.token = localStorage.token
        }
        return config
    })
    // 配置服务器默认请求地址
Vue.prototype.$baseUrl = 'http://localhost:8888'
    // 将axios挂载到Vue原型对象上
Vue.prototype.$http = axios
Vue.prototype.$ELEMENT = { size: 'small' };
// 将格式化时间的方法挂载到Vue原型对象上
Vue.prototype.$dayjs = dayjs

new Vue({
    router,
    created() {
        Vue.prototype.$bus = this
    },
    render: h => h(App)
}).$mount('#app')